﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
using NModbus.Device;
using System.IO.Ports;

namespace AgvController
{
    class Tag<T>
    {
        private Timer t;
        public T value;
        public int refreshInterval=1000;
        public int rwType;

        public int address;
        public Tag(int address,int rwType)
        {
            this.address = address;
            this.rwType = rwType;
            if (rwType==1)
            {
                t = new Timer(refreshInterval);
                t.Elapsed += T_Elapsed;
                t.AutoReset = true;
                t.Enabled = true;
            }         
        }

        private void T_Elapsed(object sender, ElapsedEventArgs e)
        {
            Type t = typeof(T);
            switch (Type.GetTypeCode(t))
            {
                case TypeCode.Empty:
                    break;
                case TypeCode.Object:
                    break;
                case TypeCode.DBNull:
                    break;
                case TypeCode.Boolean:

                    break;
                case TypeCode.Char:
                    break;
                case TypeCode.SByte:
                    break;
                case TypeCode.Byte:
                    break;
                case TypeCode.Int16:
                    break;
                case TypeCode.UInt16:
                    break;
                case TypeCode.Int32:
                    break;
                case TypeCode.UInt32:
                    break;
                case TypeCode.Int64:
                    break;
                case TypeCode.UInt64:
                    break;
                case TypeCode.Single:
                    break;
                case TypeCode.Double:
                    break;
                case TypeCode.Decimal:
                    break;
                case TypeCode.DateTime:
                    break;
                case TypeCode.String:
                    break;
                default:
                    break;
            }
        }

        private void Execute()
        {

        }
    }
}
